package org.forwhat.filter;

import jakarta.servlet.*;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * @projectName: ForWhat
 * @package: org.forwhat.filter
 * @className: CORSFilter
 * @author: LGJ
 * @description: TODO
 * @date: 2023/11/24 9:34
 * @version: 1.0
 */
public class CORSFilter extends HttpFilter {
    @Override
    protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
        response.setHeader("Access-Control-Allow-Origin", "http://localhost:63343");
        response.setHeader("Access-Control-Allow-Credentials","true");
        response.setHeader("Access-Control-Allow-Headers", "Content-Type");

        response.setContentType("application/x-www-form-urlencoded;charset=UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        chain.doFilter(request,response);
        return;
    }


}
